
#ifndef MANGA_UI_LOGIC_H
#define MANGA_UI_LOGIC_H

#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QHBoxLayout>
#include "Manga_ui.h"
#include "Product.h"
#include "globals.h"
#include "shoppingcart_ui_logic.h"

class EventGridWidget : public QWidget
{
    Q_OBJECT

public:
    explicit EventGridWidget( QWidget *parent = nullptr);
    void setEventData(QPixmap image,
                      QString theme,
                      QDate date,
                      QString location,
                      QString price,
                      QString description,
                      int productId,
                      int index);
    ~EventGridWidget();
    void populateEventWidgets();



private:
    QVBoxLayout *mainLayout;
    QVBoxLayout *eventListLayout;
    QHBoxLayout *paginationLayout;

    QList<EventDisplayWidget *> *eventWidgets;       // 可修改的列表
    int currentPage = 0;
    const int itemsPerPage = 6;

    void updatePagination();
    void loadPage(int page);

private slots:
    /*void handleBuyButtonClicked(const QString &productName,
                                const QString &productPrice,
                                int productId);*/
    void nextPage();
    void previousPage();
    void showProductDetail(const QPixmap &image, const QString &theme, const QString &description,
                           const QString &location, const QString date,const QString &price, int productId);
};

#endif // MANGA_UI_LOGIC_H
